home *** CD-ROM | disk | FTP | other *** search
- Path: lk-hp-10.hut.fi!casper
- From: casper@lk-hp-10.hut.fi (Casper Gripenberg)
- Newsgroups: comp.lang.c++
- Subject: Is it possible to use templates with structures?
- Date: 1 Feb 1996 11:57:57 GMT
- Organization: Helsinki University of Technology
- Distribution: inet
- Message-ID: <4eq9s5$l14@nntp.hut.fi>
- NNTP-Posting-Host: lk-hp-10.hut.fi
-
-
-
- Can I do:
-
- template<class T>
- struct Foo {
- T *data;
- };
-
- ??
-
- The compiler doesn't seem to complain but I would still like to be
- sure if it's ok to do it.
-
- The reason I want to do it is that I need to allocate the structure
- with my own allocation routine and not with new. Also I can't override
- new in the class so that won't work either. While on the same subject
- could I have a template class dontaining just data members and
- no constructors/destructor or memberfunctions and then allocate
- it without using new? As I understand it the only thing new does
- that for example malloc doesn't do is run the constructor code. So
- is it safe to use that kind of a template class allocated with malloc??
-
- Thanks...
-
- // Casper
-
-